/**
 * Created by zhaojm on 15/3/21.
 */
game.BackgroundLayer = cc.Layer.extend({
    _spriteSheet : null,
    _sprite : null,
    _action : null,
    ctor:function(){
        this._super();
        cc.spriteFrameCache.addSpriteFrames(res.backgroundlayer_plist);
        this._spriteSheet = new cc.SpriteBatchNode(res.backgroundlayer_png);
        this.addChild(this._spriteSheet);
        //this._spriteSheet.retain();

        this._action = new cc.RepeatForever(new cc.Animate(
            new cc.Animation([0, 1, 2, 3, 4].map(function (i) {
                return cc.spriteFrameCache.getSpriteFrame("bg_" + i + ".jpg");
            }), 0.08)
        ));
        //this._action.retain();

        this._sprite = new cc.Sprite('#bg_0.jpg');
        this._spriteSheet.addChild(this._sprite);
        this._sprite.setPosition(cc.p(cc.winSize.width * 0.5, cc.winSize.height * 0.5));
        //this._sprite.retain();
        this._sprite.runAction(this._action);

    },

    gameOver:function(){
        this._sprite.stopAllActions();
    },
});